package com.ruoyi.network.message;

/**
 * 发送命令生成器
 */
public class SendMessageGenerator {

    /**
     * 生成开灯指令
     * @param lightValue
     * @return
     */
    public static SendMessage generateOpenLightCommand(int lightValue){

        String dataHex = Integer.toHexString(lightValue);//5   05
        if(dataHex.length()%2==1){
            dataHex = "0"+dataHex;
        }
        SendMessage sendMessage = new SendMessage(1, 0, "24", dataHex);
        return sendMessage;
    }

    /**
     * 生成关灯指令
     * @return
     */
    public static SendMessage generateCloseLightCommand(){

        return generateOpenLightCommand(0);
    }

    /**
     * 生成开关水泵的命令
     * @param opened
     * @return
     */
    public static SendMessage generateSwithPump(boolean opened){
        String dataHex = opened?"01":"00";
        SendMessage sendMessage = new SendMessage(1, 0, "22", dataHex);
        return sendMessage;
    }


    public static SendMessage generateSwithFan(boolean opened){
        String dataHex = opened?"01":"00";
        SendMessage sendMessage = new SendMessage(1, 0, "21", dataHex);
        return sendMessage;
    }


}
